<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    @Author 硕鼠
    @Date 2020/4/6 10:24
    @Version 1.0
    @Description 获取一组元素
  -->
    <meta charset="UTF-8">
    <title>提取事件</title>
    <style>
        div{ width: 200px;height: 200px;float: left;border: 1px solid black;
        margin: 10px;
        }
    </style>
    <script>
        window.onload = function () {
            var oDiv = document.getElementsByTagName("div");//获取标签
            for (var i = 0;i < oDiv.length;i ++){
                oDiv[i].style.background = 'red';
            }

        };
    </script>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>
</html>